<template>
  <div class="com">
    <div class="weui-flex ta-c v-mdl">
      <div class="weui-flex__item">
        <div v-if="status != 'recording'">
          <sound-player :path="path"></sound-player>
        </div>
        <div v-else>dd</div>
      </div>
      <div class="weui-flex__item">
        <record-bar @ok="handleDsr"@start="status = 'recording'"></record-bar>
      </div>
      <div class="weui-flex__item">
        <div v-if="status != 'recording'">
          <div class="play-bar"><i class="if icon-play"></i></div>
        </div>
        <div v-else>dd</div>
      </div>
    </div>
  </div>
</template>

<script>
import SoundPlayer from '@/components/sound-player'
import RecordBar from '@/components/record-bar'
import * as $dsr from '@/api/dsr'
const COS_ADDR = process.env.COS_ADDR

export default {
  components: {
    SoundPlayer,
    RecordBar
  },
  props: {
    path: [String]
  },
  data () {
    return {
      status: 'unstart',
    }
  },
  methods: {
    async handleDsr (material) {
      this.status = 'dsring'
      let fileLink = COS_ADDR + material.key
      let rs = await $dsr.getAudioScore({fileLink, text: 'hello'})
      console.info(rs)
    }
  }
}
</script>

<style scoped lang="less">
@import '../assets/less/var.less';

.play-bar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  text-align: center;
  background-color: white;
  box-shadow: 0 0 5px rgba(0,0,0,.2);
  margin: 0 auto;
  i {
    line-height: 50px;
    position: relative;
    left: 4px;
    font-size: 1.6em;
  }
}
</style>
